<template>
  <div v-loading="loading" class="app-container">
    <el-row>
      <el-col v-for="(o,i) in cacheList" :key="o.id"  :xs="24" :span="0.5">
        <el-result icon="info" :title="o.title" :sub-title="o.desc">
          <template slot="icon">
            <i :key="i" :class="o.icon+' lgi main-color point'" @click="refresh(o)" />
          </template>
        </el-result>
      </el-col>
    </el-row>
  </div>

</template>

<script>
import { refreshCache } from '@/api/cache'

export default {
  name: 'Cache',
  data() {
    return {
      loading: false,
      cacheList: [
        { title: '菜单权限', desc: '用户访问菜单权限缓存', icon: 'iconfont icon-quanxian', id: 1 },
        { title: '系统参数', desc: '系统参数表元数据', icon: 'el-icon-s-tools', id: 2 },
        { title: '组织结构', desc: '部门树、用户组织结构关系', icon: 'iconfont icon-ic_org', id: 3 },
        { title: '菜单结构', desc: '菜单配置的缓存数据', icon: 'el-icon-menu', id: 4 },
        { title: '黑名单', desc: '被系统拒绝访问的客户端', icon: 'el-icon-s-release', id: 5 }
      ]
    }
  },
  mounted() {

  },
  methods: {
    refresh(o) {
      this.$confirm('确定要刷新' + o.desc + '缓存吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.loading = true
        refreshCache(o.id).then(() => {
          this.$message.success('刷新成功')
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      })
    }
  }
}
</script>
<style scoped>
  .lgi{
    font-size: 40px;
  }
</style>
